package work.smcp.workrecord;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class ResultData {

    private String id;


    @Data
    public static class Demo1 {
        @Data
        public static class Demo2 {

            private String title;

            private String author;

            private String digest;

            private String content;

            private String contentSourceUrl;

            private String thumbMediaId;

            private Integer showCoverPic;

            private Integer needOpenComment;

            private Integer onlyFansCanComment;

            private String url;

            private String thumbUrl;
        }

        private List<Demo2> items;
    }

    private Demo1 content;

    private String createTime;

    private String updateTime;


    public static ResultData form(OriginData originData) {
        ResultData result = new ResultData();
        result.id = originData.getMedia_id();
        result.createTime = "2023-11-17T07:50:17.891Z";
        result.updateTime = "2023-11-17T07:50:17.891Z";


        Demo1 demo1 = new Demo1();
        result.setContent(demo1);

        List<Demo1.Demo2> items = new ArrayList<>();
        demo1.setItems(items);
        for (OriginData.Demo1.Demo2 demo2 : originData.getContent().getNews_item()) {
            Demo1.Demo2 item = new Demo1.Demo2();
            item.title = demo2.getTitle();
            item.author = demo2.getAuthor();
            item.digest = demo2.getDigest();
            item.content = demo2.getContent();
            item.contentSourceUrl = demo2.getContent_source_url();
            item.thumbMediaId = demo2.getThumb_media_id();
            item.showCoverPic = demo2.getShow_cover_pic();
            item.url = demo2.getUrl();
            item.needOpenComment = demo2.getNeed_open_comment();
            item.onlyFansCanComment = demo2.getOnly_fans_can_comment();
            item.thumbUrl = demo2.getThumb_url();
            items.add(item);
        }

        return result;
    }
}
